﻿namespace UFIDA.U9.Cust.SH.SHFastShipBP
{
	using System;
	using System.Collections.Generic;
	using System.Text; 
	using UFSoft.UBF.AopFrame;	
	using UFSoft.UBF.Util.Context;
    using UFIDA.U9.Cust.SH.SHFastShipBE;
    using UFSoft.UBF.Business;

	/// <summary>
	/// UnHold partial 
	/// </summary>	
	public partial class UnHold 
	{	
		internal BaseStrategy Select()
		{
			return new UnHoldImpementStrategy();	
		}		
	}
	
	#region  implement strategy	
	/// <summary>
	/// Impement Implement
	/// 
	/// </summary>	
	internal partial class UnHoldImpementStrategy : BaseStrategy
	{
		public UnHoldImpementStrategy() { }

		public override object Do(object obj)
		{						
			UnHold bpObj = (UnHold)obj;
			
			//get business operation context is as follows
			//IContext context = ContextManager.Context	
			
			//auto generating code end,underside is user custom code
			//and if you Implement replace this Exception Code...
			//throw new NotImplementedException();
            if (bpObj.FastShipID <= 0) return null;
            using (ISession session = Session.Open())
            {
                SHFastShip ship = SHFastShip.Finder.FindByID(bpObj.FastShipID);
                if (ship == null) throw new Exception("查找快速出货单出错！");
                if (ship.DocState != FastShipDocState.DocHold) throw new Exception("单据状态必须为挂起，不能取消挂起！");
                ship.DocState = FastShipDocState.DocOpen;
                foreach (SHFastShipLine line in ship.SHFastShipLine)
                {
                    line.DocLineState = FastShipDocState.DocOpen;
                }
                session.Commit();
            }
            return null;
		}		
	}

	#endregion
	
	
}